/**
 * Project 67th
 */


#ifndef _EVENTFD_H
#define _EVENTFD_H

#include <functional>
using std::function;
using std::bind;

using EventfdCallback = function<void()>;

class Eventfd {
public: 

    /**
     * @param cb
     */
    Eventfd(EventfdCallback && cb);

    ~Eventfd();

    void start();

    void stop();

    int createEventFd();

    void handleRead();

    void wakeup();
private: 
    int _evtfd;
    EventfdCallback _cb;
    bool _isStarted;
};

#endif //_EVENTFD_H
